import httpUtil from '../utils/request'

export function sqlPage(params){
    return httpUtil({
        url: '/sql/page',
        method: 'get',
        params: params
    })
}

export function sqlInfo(ns,ds,mns,sqlId){
    return httpUtil({
        url: '/sql/info/',
        method: 'get',
        params: {
            ns,
            ds,
            mns,
            sqlId
        }
    })
}

export function sqlLogPage(params){
    return httpUtil({
        url: '/sql/log/page',
        method: 'get',
        params: params
    })
}

export function sqlExec(data){
    return httpUtil({
        url: '/exec/mapper/sql',
        method: 'post',
        data: data
    })
}

export function sqlTest(params){
    const data = {
        ns:params.ns,
        ds:params.ds,
        mns:params.mns,
        sqlId:params.sqlId,
        page:params.page,
        limit:params.limit,
        params:params.params,
        sqlResponseMapper:params.sqlResponseMapper,
        sqlStatement:params.sqlStatement,
        sqlType:params.sqlType
    }
    return httpUtil({
        url: '/sql/test',
        method: 'post',
        data: data
    })
}

export function sqlList(ns,ds,page,limit){
    const params = {
        ns,
        ds,
        page,
        limit,
    }
    return httpUtil({
        url: '/sql/page',
        method: 'get',
        params: params
    })
}

export function sqlDel(ns,ds,mns,sqlIds){
    const data = {
        ns,
        ds,
        mns,
        sqlIds
    }
    return httpUtil({
        url: '/sql/del',
        method: 'post',
        data: data
    })
}

export function sqlAdd(params){
    const data = {
        ns:params.ns,
        ds:params.ds,
        mns:params.mns,
        sqlId:params.sqlId,
        sqlStatement:params.sqlStatement,
        sqlType:params.sqlType
    }
    return httpUtil({
        url: '/sql/add',
        method: 'post',
        data: data
    })
}

export function sqlUpdate(from){
    const data = {
        ns:from.ns,
        ds:from.ds,
        mns:from.mns,
        sqlId:from.sqlId,
        sqlStatement:from.sqlStatement,
        description:from.description
      }
    return httpUtil({
        url: '/sql/update',
        method: 'post',
        data: data
    })
}

